import { PrimaryGeneratedColumn, Column, Entity, OneToOne } from 'typeorm'
import { MaterialContent } from './material-content.entity'

@Entity()
export class Material {
  @PrimaryGeneratedColumn()
  id: number

  @Column({
    unique: true
  })
  media_id: string

  @Column({
    default: ''
  })
  media_type: string

  @Column({
    default: ''
  })
  name: string

  @Column({
    default: 0
  })
  update_time: number

  @Column({
    default: ''
  })
  url: string

  // 主表
  @OneToOne(type => MaterialContent, content => content.material, {
    cascade: ['insert'],
    eager: true
  })
  content: MaterialContent
}
